define(['../data/pm25'
  , '../data/geoCoordMap'
  , '../option/geo'
  , 'lodash'], function(pm25, geoCoordMap, option, _) {

  var convertData = function (data) {
      var res = [];
      for (var i = 0; i < data.length; i++) {
          var geoCoord = geoCoordMap[data[i].name];
          if (geoCoord) {
              res.push({
                  name: data[i].name,
                  value: geoCoord.concat(data[i].value)
              });
          }
      }
      return res;
  };

  var option = _.merge({}, option, {
    xAxis: {
        type: 'value',
        scale: true,
        position: 'top',
        boundaryGap: false,
        splitLine: {show: false},
        axisLine: {show: false},
        axisTick: {show: false},
        axisLabel: {margin: 2, textStyle: {color: '#aaa'}},
    },
    yAxis: {
        type: 'category',
        name: 'TOP 20',
        nameGap: 16,
        axisLine: {show: false, lineStyle: {color: '#ddd'}},
        axisTick: {show: false, lineStyle: {color: '#ddd'}},
        axisLabel: {interval: 0, textStyle: {color: '#ddd'}},
        data: []
    },
    series: [{
      name: 'pm2.5',
      type: 'effectScatter',
      coordinateSystem: 'geo',
      rippleEffect: {
        scale: 1,
        period: 4,
        brushType: 'stroke'
      },
      symbol: 'rect',
      data: convertData(pm25.data),
      symbol: 'image://ceng2.png',
      symbolSize: function (val) {
        return Math.log(val[2]) * 5
      },
      // symbolSize: 2,
      label: {
          normal: {
              show: false
          },
          emphasis: {
              show: false
          }
      },
      itemStyle: {
        normal: {
          color: '#fff',
          opacity: 0
        },
          emphasis: {
            opacity: 0,
              borderColor: '#fff',
              borderWidth: 1
          }
      }
    }]
  })

  return option;
})